<?php
switch($_POST["hidden"])
{

	case "";
	// khoi dau trang khong co gia tri submit. khong lam zi ca
	break;
	
	/* khoi su ly su kien submit form news */
	case "submit_com_contact_add";
		$ispostback = $_POST["ispostback"];
		if($ispostback == 0){
			$myprocess = new process;
			if($myprocess->process_addcontact($_POST["fullname"], $_POST["email"], $_POST["company"], $_POST["address"], $_POST["tel"], $_POST["fax"] , $_POST["subject"], $_POST["comments"], $core_class->_formatdatetime(date("d/m/Y")), "0") <> FALSE){
				$core_class->_redirect(".?com=com_contact&msg=Thông tin liên hệ của bạn đã được gửi thành công!");
			} else {
				$core_class->_redirect(".?com=com_contact&msg=Đã có lỗi thêm chủ đề, vui lòng làm lại!");
			}
		}
	break;
	
	default:
		$core_class->_redirect(".");exit();
	break;
	
}

class process{
	// ham su ly them tin moi
	function process_addcontact($name, $email, $company, $address, $phone, $fax, $title, $content, $date_add, $view){
		$myprocess = new process;
		include("protected/dbconnect.php");
		$sql = "INSERT INTO contact (`name`, `email`, `company`, `address`, `phone`, `fax`, `title`, `content`, `date_add`, `view`)
				VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
		$cmd = $mysqli->prepare($sql);
		$cmd->bind_param("ssssssssss", $name, $email, $company, $address, $phone, $fax, $title, $content, $date_add, $view);
		if($cmd->execute() <> FALSE) return true; 
		else echo $mysqli->error;
		$cmd->close();
		$mysqli->close();				
	}
}
?>